From: Marco Trevisan (TreviƱo) Date: Tue, 2 Dec 2025 03:12:30 +0000 (+0100) Subject: environment: Ignore prepare/cleanup in no duration animations X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~55^2^2~12 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=58f0e3d55429bf08d14cc3d8c9dd780bbb57eba2;p=gnome-shell.git environment: Ignore prepare/cleanup in no duration animations These animations are just completing immediately, so there is no need to increase the complexity by calling unneeded code Part-of: (cherry picked from commit c4009e87d0120e3e769a3e28b6a0fdb36d7b443d) --- diff --git a/js/ui/environment.js b/js/ui/environment.js index 1bd76374b..93e0bdbd0 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -62,7 +62,7 @@ function _makeEaseCallback(params, cleanup) { delete params.onStopped; return isFinished => { - cleanup(); + cleanup?.(); if (onStopped) onStopped(isFinished); @@ -71,7 +71,10 @@ function _makeEaseCallback(params, cleanup) { }; } -function _makeEasePrepareAndCleanup() { +function _makeEasePrepareAndCleanup(duration) { + if (!duration) + return {prepare: null, cleanup: null}; + const prepare = () => { global.compositor.disable_unredirect(); global.begin_work(); @@ -141,14 +144,15 @@ function _easeActor(actor, params) { actor.set_easing_mode(params.mode); delete params.mode; - const {prepare, cleanup} = _makeEasePrepareAndCleanup(); + const easingDuration = actor.get_easing_duration(); + const {prepare, cleanup} = _makeEasePrepareAndCleanup(easingDuration); const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transitions let animatedProps = Object.keys(params).map(p => p.replace('_', '-', 'g')); animatedProps.forEach(p => actor.remove_transition(p)); - if (actor.get_easing_duration() > 0 || !isReversed) + if (easingDuration > 0 || !isReversed) actor.set(params); actor.restore_easing_state(); @@ -160,10 +164,12 @@ function _easeActor(actor, params) { const [transition] = transitions; - if (transition && transition.delay) - transition.connectObject('started', () => prepare(), sessionSignalHolder); - else - prepare(); + if (prepare) { + if (transition?.delay) + transition.connectObject('started', () => prepare(), sessionSignalHolder); + else + prepare(); + } if (transition) { transition.connectObject('stopped', (t, finished) => callback(finished), @@ -215,7 +221,7 @@ function _easeAnimatableProperty(animatable, propName, target, params) { if (!actor?.mapped) duration = 0; - const {prepare, cleanup} = _makeEasePrepareAndCleanup(); + const {prepare, cleanup} = _makeEasePrepareAndCleanup(duration); const callback = _makeEaseCallback(params, cleanup); // cancel overwritten transition @@ -227,7 +233,7 @@ function _easeAnimatableProperty(animatable, propName, target, params) { if (!isReversed) obj[prop] = target; - prepare(); + prepare?.(); callback(true); return; @@ -246,10 +252,12 @@ function _easeAnimatableProperty(animatable, propName, target, params) { transition.set_to(target); - if (transition.delay) - transition.connectObject('started', () => prepare(), sessionSignalHolder); - else - prepare(); + if (prepare) { + if (transition.delay) + transition.connectObject('started', () => prepare(), sessionSignalHolder); + else + prepare(); + } transition.connectObject('stopped', (t, finished) => callback(finished), sessionSignalHolder);